//
//  UIBarButtonItem+Extension.swift
//  微博三天
//
//  Created by jessica on 15/11/19.
//  Copyright © 2015年 jessica. All rights reserved.
//

import UIKit

extension UIBarButtonItem {

//自定义BarButtonItem 的便利构造函数
    convenience init(imageName : String,target : AnyObject?,actionName : String?) {
        
        let btn = UIButton(type: .Custom)
        btn.setImage(UIImage(named: imageName), forState:.Normal)
        btn.setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        
        if let action = actionName, targetObj = target {
        
        btn.addTarget(targetObj, action: Selector(action), forControlEvents:.TouchUpInside)
            
        }
              
       btn.sizeToFit()
        self.init(customView : btn)
    }

 }
